home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group03a.txt / 000055_icon-group-sender_Thu Mar 27 07:51:13 2003.msg < prev    next >
Internet Message Format  |  2003-12-22  |  6KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id h2REnoI09250
  4.     for icon-group-addresses; Thu, 27 Mar 2003 07:49:50 -0700 (MST)
  5. Message-Id: <200303271449.h2REnoI09250@baskerville.CS.Arizona.EDU>
  6. X-Newsgroups: comp.lang.icon
  7. Subject: Re: Icon-like programming language - 2 attachments
  8. From: Raja Mukherji <rapl_lang@yahoo.co.uk>
  9. User-Agent: Xnews/5.04.25
  10. X-NNTP-Posting-Host: 10145phys232.ucd.ie
  11. Date: 27 Mar 2003 09:19:01 GMT
  12. To: icon-group@cs.arizona.edu
  13. Errors-To: icon-group-errors@cs.arizona.edu
  14. Status: RO
  15.  
  16. I've already looked at Idol and Unicon and although they support OOP, they 
  17. don't provide operator/function overloading (Unicon says it will, but I 
  18. don't think it will be similar to my method). Also, they don't support 
  19. currying of functions (although I suppose you could implement it in 
  20. Idol/Unicon using classes). However, Rapl was originally written to be a 
  21. faster Icon (written in x86 assembly) without looking at the Icon source 
  22. code, to see if I could do it. I have since looked at the source code and 
  23. feel that extending Icon with new internal types is fairly difficult. I use 
  24. a method table for each internal types (much like Jcon) which also makes it 
  25. faster (currently Rapl code runs approx 3-5 times faster than Icon although 
  26. I haven't tested all features yet).
  27.  
  28. Part of the reason I wrote Rapl is that at the time, there was no real 
  29. attempt to support dynamic native function loading on windows platforms, 
  30. which I use (Unicon promises it in the next release but I started Rapl 3 
  31. years ago). Rapl doesn't support dynamic loading yet actually, it currently 
  32. only supports dynamic linking (all modules are loaded only when needed). 
  33. Similarly, it allows initialization of global constants/variables,  which 
  34. are only initialized when required. The module system provides no way of 
  35. telling the difference between native and bytecode module, indeed my 
  36. current compiled module file format can contain a mixture of both.
  37.  
  38. The ease that I think new types can be added to Rapl and the lack of 
  39. distinction between native and bytecode modules means (in my opinion) that 
  40. the language can be extended fairly easily by independent people at 
  41. independant times much more so than Icon.
  42.  
  43. Also, I wanted to make the language more uniform than Icon, there are no 
  44. procedure/record declarations, only constants and variables which may be 
  45. assigned functions and types. There are no pre-defined functions, only 
  46. imported ones. Everything is an object, including integers, strings, lists, 
  47. etc, although internal layering means that performance is not affected as a 
  48. results.
  49.  
  50. Lastly I gave Rapl "symbols", written as .<ident> where there act as simple 
  51. immutable values, with the restriction that when any program is running, 
  52. .<ident1> = .<ident2> if and only if <ident1> = <ident2>, regardless of 
  53. which module they are being used in. (Again this could be done using tables 
  54. in Icon but I think my way is faster and simpler). For example, .a, .e, and 
  55. .b are used for comparisions (above, equal or below) which can then be 
  56. redefined for use in tables/sets for example.
  57.  
  58. Here's an example of overloading as done in Rapl,
  59.  
  60. #####################################################################
  61. mod test;
  62.  
  63. imp sys use write;                ## sys is a native module
  64. imp riva use                        ## riva is the name of the system module
  65.         real,                            ## real is the class of real numbers
  66.       Mul,                            ## Mul is the name of the operator '*'
  67.         Add,                            ## Add is the name of the operator '+'
  68.         Comp;                        ## Comp is used for comparisions
  69.                                         ## and is the name of the operator '?'
  70. imp math;
  71.  
  72. def vector is (
  73.         def v is type(X, Y, Z) (
  74.                 new is ovrl fun() fail;        ## constructor
  75.                                                         ## ovrl <x> = overload with
  76.                                                     ## default <x>
  77.                 size is fun() math.sqrt(Self.X^2+Self.Y^2+Self.Z^2);
  78.                 strn is fun() "(" + Self.X + ", " + Self.Y + ", " + 
  79.                         Self.Z + ")";
  80.         );
  81.  
  82.         v.new[real][real][real] <- fun(X, Y, Z) ( ## constructor for reals
  83.                 Self.X <- X; Self.Y <- Y; Self.Z <- Z;
  84.                 ret Self;
  85.         );
  86.         v.new[vector] <- fun(V) ( ## copying constructor for vectors
  87.                 Self.X <- V.X; Self.Y <- V.Y; Self.Z <- V.Z;
  88.                 ret Self;
  89.         );
  90.  
  91.         Add[vector][vector] <- fun(A, B) vector(A.X+B.X, A.Y+B.Y, A.Z+B.X);
  92.         Mul[real][vector] <- fun(K, A) vector(K*A.X, K*A.Y, K*A.Z);
  93.         Comp[vector][vector] <- fun(A, B) A.size() ? B.size();
  94.         ## compare based on size: returns .b, .e or .a
  95.         v;        ## finally set vector to our temporary type v
  96. );
  97.  
  98. def start! is (        ## ! = exported symbol
  99.         var A <- vector(10.0, 20.0, 10.0);
  100.         write(A, "\n");        ## will use A.strn()
  101.         var B <- vector(A);
  102.         B.X <- 30.0;
  103.         write(B, "\n");
  104.         var C <- A + B;
  105.         var D <- 0.1 * C;
  106.         write(D, "\n");
  107.         write(if A > D then "A is bigger then
  108.                 D\n"
  109.         else
  110.                 "A is not bigger than D\n"
  111.         );
  112. );
  113. #####################################################################
  114.  
  115. Anyway, thanks for the comment. I don't think I'm reinventing the wheel, 
  116. meerly adding tyres to make it more useful, although I could be wrong...
  117.  
  118. "Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net> wrote in
  119. news:UOlga.7606$kU.6828@nwrdny01.gnilink.net: 
  120.  
  121. > My advise is that you should avoid re-inventing the wheel. Some of the
  122. > features of the 'Rapl' are parts of Icon and Icon extensions. For
  123. > example, Icon already supports dynamic loading of other programs (the
  124. > load function for Icon code, the loadfunc function for native code).
  125. > An OO extension of Icon is available through the Idol preprocessor,
  126. > and also through the Unicon language (http://unicon.sourceforge.net/).
  127. > You may want to take a look at these languages before duplicating work
  128. > that has been done already. 
  129.  
  130.